package com.example.demo.tree;

import java.util.Enumeration;
import java.util.Stack;

/**
 * Created by 蔡超 on 2018/10/9.
 */
public class StackDemo {

    public void print(Stack<String> stack){
        if(stack.empty()){
            System.out.println("栈是空的");
        }else{
            Enumeration enumeration = stack.elements();
            while (enumeration.hasMoreElements()){
                System.out.println(enumeration.nextElement());
            }
        }
    }

    public static void main(String[] args) {
        StackDemo stackDemo = new StackDemo();

        Stack<String> stack = new Stack<>();
        stack.push("aa");
//        stackDemo.print(stack);
        stack.push("bb");
        stackDemo.print(stack);
        System.out.println(stack.search("aa"));
        System.out.println(stack.search("bb"));
        stack.pop();
        stackDemo.print(stack);
    }
}

